package projectchumashgeniusproject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class Phrase implements Serializable
{
    private int phraseNum;
    private String hebrew, englishTranslation, displayHebrew;
    private List<Word> words;
    
    public Phrase(int pn, String h, String et, String dh)
    {
        this(pn, h, et, dh, new ArrayList<Word>());
    }
    public Phrase(int pn, String h, String et, String dh, ArrayList<Word> w)
    {
        this.phraseNum = pn;
        this.hebrew = h;
        this.englishTranslation = et;
        this.displayHebrew = dh;
        this.words = new ArrayList<>(w);
    }
    public int getPhraseNumber()
    {
        int pn = phraseNum;
        return pn;
    }
    public String getHebrew()
    {
        return hebrew;
    }
    public String getEnglishTranslation()
    {
        return englishTranslation;
    }
    public String getDisplayHebrew()
    {
        return displayHebrew;
    }
    public List<Word> getWords()
    {
        return new ArrayList<>(words);
    }
    public void addWord(Word w)
    {
        words.add(w.getWordNumber() - 1, w);
    }
    @Override
    public int hashCode()
    {
        int hash = 3;
        hash = 47 * hash + this.phraseNum;
        hash = 47 * hash + Objects.hashCode(this.hebrew);
        hash = 47 * hash + Objects.hashCode(this.englishTranslation);
        hash = 47 * hash + Objects.hashCode(this.displayHebrew);
        hash = 47 * hash + Objects.hashCode(this.words);
        return hash;
    }
    @Override
    public boolean equals(Object obj)
    {
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        
        final Phrase other = (Phrase) obj;
        
        if (this.phraseNum != other.phraseNum)
            return false;
        if (!Objects.equals(this.hebrew, other.hebrew))
            return false;
        if (!Objects.equals(this.englishTranslation, other.englishTranslation))
            return false;
        if (!Objects.equals(this.displayHebrew, other.displayHebrew))
            return false;
        if (!Objects.equals(this.words, other.words))
            return false;
        
        return true;
    }
    public boolean isEquivlant(Object obj)
    {
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        
        final Phrase other = (Phrase) obj;
        
        if (!Objects.equals(this.hebrew, other.hebrew))
            return false;
        if (!Objects.equals(this.englishTranslation, other.englishTranslation))
            return false;
        if (!Objects.equals(this.displayHebrew, other.displayHebrew))
            return false;
        if (!Objects.equals(this.words, other.words))
            return false;
        
        return true;
    }
}